// Author: wsfuyibing <682805@qq.com>
// Date: 2025-05-01

package verify

import (
	"server/app/lib"
	"server/app/lib/encryption"
)

// Request
// 校验入参.
//
// 二维码的ID与签名, 扫码后能拿到, 签名用于防止伪造ID号.
type Request struct {
	Code       encryption.Encryption `json:"code" validate:"required,min=8,max=28" label:"二维码内容"`
	QrcodeId   int64                 `json:"-" validate:"required,min=1" label:"二维码ID"`
	QrcodeSign string                `json:"-" validate:"required,min=6,max=6" label:"二维码签名"`
}

// func (o *Request) AfterValidate() (err error) {
//     o.QrcodeId, o.QrcodeSign, err = lib.Encryption.DecodeQrcode(o.Code)
//     return
// }

func (o *Request) BeforeValidate() (err error) {
	o.QrcodeId, o.QrcodeSign, err = lib.Encryption.DecodeQrcode(o.Code)
	return
}
